<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<%@ include file="/commons/head.jsp" %>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <%@ include file="/commons/left.jsp" %>
    <div class="content-wrapper">
        <section class="content-header">
            <h1>
                商标信息
            </h1>
        </section>
        <div class="content">
            <div class="row">
                <div class="col-md-9">
                    <div class="box box-primary" style="overflow:hidden">
                        <form id="postForm" enctype="multipart/form-data" class="form-horizontal" autocomplete="off">
                            <input type="hidden" name="Id" value="${entity.id}">
                            <div class="box-body" style="padding-top:30px">
                                <div class="form-group">
                                    <label for="inputBrandName" class="col-sm-2 control-label">商标名称：</label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control" autocomplete="off" id="inputBrandName"
                                               name="brandName" value="${entity.brandName}" placeholder="商标名称">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="multipartFile" class="col-sm-2 control-label">商标图</label>
                                    <div class="col-sm-5"><input id="multipartFile" name="multipartFile" type="file"
                                                                 accept="image/*"
                                                                 style="margin-top: 5px;"></div>
                                </div>
                                <div class="form-group">
                                    <label for="inputEnterpriseName" class="col-sm-2 control-label">企业名称：</label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control" autocomplete="off" id="inputEnterpriseName"
                                               name="enterpriseName" value="${entity.enterpriseName}" placeholder="企业名称">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputCategory" class="col-sm-2 control-label">类别：</label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control" autocomplete="off" id="inputCategory"
                                               name="category" value="${entity.category}" placeholder="类别">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputCommodity" class="col-sm-2 control-label">商品：</label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control" autocomplete="off" id="inputCommodity"
                                               name="commodity" value="${entity.commodity}" placeholder="商品">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputIdentiTime" class="col-sm-2 control-label">认定时间：</label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control" autocomplete="off" id="inputIdentiTime"
                                               name="identiTime" value='<fmt:formatDate pattern="yyyy-MM-dd" value="${entity.identiTime}"/>' readonly="readonly"
                                               onfocus="WdatePicker()" placeholder="认定时间">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="selectIsStatis" class="col-sm-2 control-label">状态：</label>
                                    <div class="col-sm-3">
                                        <select class="form-control select2 select2-hidden-accessible"
                                                id="selectIsStatis"
                                                style="width: 100%;" tabindex="-1" aria-hidden="true" name="isStatis">
                                            <option value="0" <c:if test="${0 == entity.isStatis}">selected="selected"</c:if>>禁用</option>
                                            <option value="1" <c:if test="${1 == entity.isStatis}">selected="selected"</c:if>>启用</option>
                                            <option value="2" <c:if test="${2 == entity.isStatis}">selected="selected"</c:if>>推荐</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="box-footer">
                                <div class="col-sm-2"></div>
                                <button type="button" class="btn btn-info" onclick="submitForm()">提交</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <%@ include file="/commons/script.jsp" %>
    <script type="text/javascript" src="${ctx}/dist/js/jquery.form.js"></script>
    <script type="text/javascript" src="${ctx}/plugins/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript">

        function submitForm() {
            var id = $('#postForm').find('input[name=Id]').val();
            var url = null;
            if (id == null || id == "") {
                url = "${ctx}/trademark/saveTrademark?action=add";
            } else {
                url = "${ctx}/trademark/saveTrademark?action=update";
            }
            $("#postForm").ajaxSubmit({
                cache: false,
                type: "post",
                url: url,
                error: function () {
                    alert("系统异常");
                },
                success: function (data) {
                    if (data !== null) {
                        if (data == 0) {
                            //修改失败
                            alert('失败');
                        } else {
                            //添加/修改成功
                            alert('成功');
                            window.location.href = "${ctx}/trademark/listTrademark";
                        }
                    }
                }
            });
        }
    </script>
</body>
</html>
